package com.tanhua.server.controller;

import com.tanhua.domain.vo.RecommendQueryVo;
import com.tanhua.server.service.IMService;
import com.tanhua.server.service.TodayBestService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.lang.reflect.InvocationTargetException;
import java.util.Map;

@RestController
@RequestMapping("/tanhua")
public class
TodayBestController {

    @Autowired
    private TodayBestService todayBestService;

    @Autowired
    private IMService imService;

    @GetMapping("/todayBest")
    public ResponseEntity<Object> todayBest() throws InvocationTargetException, IllegalAccessException {
        return todayBestService.getTodayBest();
    }

    @GetMapping("/recommendation")
    public ResponseEntity<Object> recommendation(RecommendQueryVo vo){
        return todayBestService.recommendation(vo);
    }

    @GetMapping("{id}/personalInfo")
    public ResponseEntity<Object> personalInfo(@PathVariable("id") Long id) throws InvocationTargetException, IllegalAccessException {
        return todayBestService.queryPersonalInfo(id);
    }

    @GetMapping("/strangerQuestions")
    public ResponseEntity<Object> strangeQuestions(Long userId){
        return todayBestService.showStrangeQuestions(userId);
    }

    @PostMapping("/strangerQuestions")
    public ResponseEntity<Object> strangeQuestionsReply(@RequestBody Map<String,Object> params){
        Integer userId = (Integer)params.get("userId");
        String reply = (String)params.get("reply");
        return imService.strangeQuestionsReply(userId,reply);
    }

    //搜附近的人
    @GetMapping("/search")
    public ResponseEntity<Object> search(String gender, Long distance) throws InvocationTargetException, IllegalAccessException {
        return todayBestService.searchNearBy(gender,distance);
    }
}
